<html>
<!-- 
  Copyright 2010 Scott Logic Ltd.
  http://www.scottlogic.co.uk
  
  This file is part of Closure Charts.

  Closure Charts is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Closure Charts is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with Closure Charts.  If not, see <http://www.gnu.org/licenses/>.
-->
<head>
<title>JavaScript Charting Unit Tests - Context</title>
<script type="text/javascript" src="../../../../../../../../closure-library/src/main/webapp/js/goog/base.js"></script>
<script type="text/javascript" src="../unitTestDependencies.js"></script>
<script>
    goog.require('goog.testing.jsunit');
    goog.require('goog.dom');
    goog.require('goog.graphics');
    goog.require('goog.math');
    goog.require('goog.array');

    goog.require('scottlogic.chart.rendering.Context');
</script>
</head>
<body>
<script>  
    // Clear the canvas after the charts have been tested
    function tearDown(){
        var canvas = goog.dom.$('canvas');
        canvas.innerHTML = '';
    }

    function testConvertPath(){
        var plottingArea = new goog.math.Rect(0, 0, 5, 5);
        
        var horizontalPath = new goog.graphics.Path();
        horizontalPath.moveTo(-5, 2.5);
        horizontalPath.lineTo(10, 2.5);

        var horizontalPath_result = new goog.graphics.Path();
        horizontalPath_result.moveTo(0, 2.5);
        horizontalPath_result.lineTo(5, 2.5);

        var verticalPath = new goog.graphics.Path();
        verticalPath.moveTo(2.5, -5);
        verticalPath.lineTo(2.5, 10);

        var verticalPath_result = new goog.graphics.Path();
        verticalPath_result.moveTo(2.5, 0);
        verticalPath_result.lineTo(2.5, 5);

        var context = new scottlogic.chart.rendering.Context(plottingArea);
        
        assertTrue("Horizontal path", goog.array.equals(horizontalPath_result.segments_, context.convertPath(horizontalPath).segments_));
        assertTrue("Vertical path", goog.array.equals(verticalPath_result.segments_, context.convertPath(verticalPath).segments_));
    }
</script>
<div id="canvas"></div>
</body>
</html>
